import axios from 'axios';

// 返回播放需要的数据
export async function playData(id) {
    let { data } = await axios.get(`/song/detail?ids=${id}`);
    data = data.songs[0];
    return {
        id: data.id,
        songName: data.name,
        singer: data.ar,
        picUrl: data.al.picUrl
    }
}


// 计算时间
export const computedPlayTime = (millisecond) => {
    let second = millisecond / 1000;
    second = (second / 60).toString();
    second = second.split('.');
    second[0] = second[0].length != 2 ? '0' + second[0] : second[0];
    second[1] = parseInt(Number('0.' + second[1]) * 60);
    second[1] = second[1].toString().length == 1 ? `0${second[1]}` : second[1];
    return `${second[0]}:${second[1]}`
}
